! function(t, s) {
	"object" == typeof exports && "undefined" != typeof module ? module.exports = s() : "function" == typeof define &&
		define.amd ? define(s) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs_plugin_duration =
		s()
}(this, function() {
	"use strict";

	function r(t) {
		return t instanceof y
	}

	function o(t, s, n) {
		return new y(t, n, s.$l)
	}

	function e(t) {
		return a.p(t) + "s"
	}

	function n(t) {
		return t < 0 ? Math.ceil(t) : Math.floor(t)
	}

	function d(t, s) {
		return t ? t < 0 ? {
			negative: !0,
			format: "" + Math.abs(t) + s
		} : {
			negative: !1,
			format: "" + t + s
		} : {
			negative: !1,
			format: ""
		}
	}

	function u(t, s, n) {
		return t.add(s.years() * n, "y").add(s.months() * n, "M").add(s.days() * n, "d").add(s.hours() * n, "h")
			.add(s.minutes() * n, "m").add(s.seconds() * n, "s").add(s.milliseconds() * n, "ms")
	}
	var h, a, t, s = 36e5,
		i = 864e5,
		c = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,
		f = 31536e6,
		m = 2628e6,
		l =
		/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,
		$ = {
			years: f,
			months: m,
			days: i,
			hours: s,
			minutes: 6e4,
			seconds: 1e3,
			milliseconds: 1,
			weeks: 6048e5
		},
		y = ((t = g.prototype).calMilliseconds = function() {
			var n = this;
			this.$ms = Object.keys(this.$d).reduce(function(t, s) {
				return t + (n.$d[s] || 0) * $[s]
			}, 0)
		}, t.parseFromMilliseconds = function() {
			var t = this.$ms;
			this.$d.years = n(t / f), this.$d.months = n((t %= f) / m), this.$d.days = n((t %= m) / i), this.$d
				.hours = n((t %= i) / s), this.$d.minutes = n((t %= s) / 6e4), this.$d.seconds = n((t %= 6e4) /
					1e3), this.$d.milliseconds = t %= 1e3
		}, t.toISOString = function() {
			var t = d(this.$d.years, "Y"),
				s = d(this.$d.months, "M"),
				n = +this.$d.days || 0,
				n = (this.$d.weeks && (n += 7 * this.$d.weeks), d(n, "D")),
				i = d(this.$d.hours, "H"),
				e = d(this.$d.minutes, "M"),
				r = this.$d.seconds || 0,
				r = (this.$d.milliseconds && (r += this.$d.milliseconds / 1e3, r = Math.round(1e3 * r) / 1e3),
					d(r, "S")),
				o = t.negative || s.negative || n.negative || i.negative || e.negative || r.negative,
				u = i.format || e.format || r.format ? "T" : "",
				o = (o ? "-" : "") + "P" + t.format + s.format + n.format + u + i.format + e.format + r.format;
			return "P" == o || "-P" == o ? "P0D" : o
		}, t.toJSON = function() {
			return this.toISOString()
		}, t.format = function(t) {
			var t = t || "YYYY-MM-DDTHH:mm:ss",
				n = {
					Y: this.$d.years,
					YY: a.s(this.$d.years, 2, "0"),
					YYYY: a.s(this.$d.years, 4, "0"),
					M: this.$d.months,
					MM: a.s(this.$d.months, 2, "0"),
					D: this.$d.days,
					DD: a.s(this.$d.days, 2, "0"),
					H: this.$d.hours,
					HH: a.s(this.$d.hours, 2, "0"),
					m: this.$d.minutes,
					mm: a.s(this.$d.minutes, 2, "0"),
					s: this.$d.seconds,
					ss: a.s(this.$d.seconds, 2, "0"),
					SSS: a.s(this.$d.milliseconds, 3, "0")
				};
			return t.replace(c, function(t, s) {
				return s || String(n[t])
			})
		}, t.as = function(t) {
			return this.$ms / $[e(t)]
		}, t.get = function(t) {
			var s = this.$ms,
				t = e(t);
			return "milliseconds" === t ? s %= 1e3 : s = "weeks" === t ? n(s / $[t]) : this.$d[t], s || 0
		}, t.add = function(t, s, n) {
			s = s ? t * $[e(s)] : (r(t) ? t : o(t, this)).$ms;
			return o(this.$ms + s * (n ? -1 : 1), this)
		}, t.subtract = function(t, s) {
			return this.add(t, s, !0)
		}, t.locale = function(t) {
			var s = this.clone();
			return s.$l = t, s
		}, t.clone = function() {
			return o(this.$ms, this)
		}, t.humanize = function(t) {
			return h().add(this.$ms, "ms").locale(this.$l).fromNow(!t)
		}, t.valueOf = function() {
			return this.asMilliseconds()
		}, t.milliseconds = function() {
			return this.get("milliseconds")
		}, t.asMilliseconds = function() {
			return this.as("milliseconds")
		}, t.seconds = function() {
			return this.get("seconds")
		}, t.asSeconds = function() {
			return this.as("seconds")
		}, t.minutes = function() {
			return this.get("minutes")
		}, t.asMinutes = function() {
			return this.as("minutes")
		}, t.hours = function() {
			return this.get("hours")
		}, t.asHours = function() {
			return this.as("hours")
		}, t.days = function() {
			return this.get("days")
		}, t.asDays = function() {
			return this.as("days")
		}, t.weeks = function() {
			return this.get("weeks")
		}, t.asWeeks = function() {
			return this.as("weeks")
		}, t.months = function() {
			return this.get("months")
		}, t.asMonths = function() {
			return this.as("months")
		}, t.years = function() {
			return this.get("years")
		}, t.asYears = function() {
			return this.as("years")
		}, g);

	function g(s, t, n) {
		var i = this;
		if (this.$d = {}, this.$l = n, void 0 === s && (this.$ms = 0, this.parseFromMilliseconds()), t) return o(s *
			$[e(t)], this);
		if ("number" == typeof s) return this.$ms = s, this.parseFromMilliseconds(), this;
		if ("object" == typeof s) return Object.keys(s).forEach(function(t) {
			i.$d[e(t)] = s[t]
		}), this.calMilliseconds(), this;
		if ("string" == typeof s) {
			n = s.match(l);
			if (n) return t = n.slice(2).map(function(t) {
					return null != t ? Number(t) : 0
				}), this.$d.years = t[0], this.$d.months = t[1], this.$d.weeks = t[2], this.$d.days = t[3], this
				.$d.hours = t[4], this.$d.minutes = t[5], this.$d.seconds = t[6], this.calMilliseconds(), this
		}
		return this
	}
	return function(t, s, i) {
		a = (h = i)().$utils(), i.duration = function(t, s) {
			var n = i.locale();
			return o(t, {
				$l: n
			}, s)
		}, i.isDuration = r;
		var n = s.prototype.add,
			e = s.prototype.subtract;
		s.prototype.add = function(t, s) {
			return r(t) ? u(this, t, 1) : n.bind(this)(t, s)
		}, s.prototype.subtract = function(t, s) {
			return r(t) ? u(this, t, -1) : e.bind(this)(t, s)
		}
	}
});